home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / answrbok / 7_5.lha / 7_5 / 7_5brect.c < prev    next >
Text File  |  1993-08-08  |  629b  |  26 lines

  1. * Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */
  2. * The C++ Answer Book */
  3. * Tony Hansen */
  4. * All rights reserved. */
  5. / Exercise 7.5
  6. / rectangle derived from a line
  7. lass rectangle : public shape
  8.  
  9.    point sw, ne;
  10.    friend class line;
  11.  
  12. ublic:
  13.    point north() { return point((sw.x+ne.x)/2,ne.y); }
  14.    point east();
  15.    point south() { return point((sw.x+ne.x)/2,sw.y); }
  16.    point west();
  17.    point neast() { return ne; }
  18.    point seast();
  19.    point swest() { return sw; }
  20.    point nwest();
  21.    void draw();
  22.    void move(int a, int b)
  23. { sw.x+=a; sw.y+=b; ne.x+=a; ne.y+=b; }
  24.    rectangle(point a, point b);
  25. ;
  26.